// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using NSQL.Sharpen;

namespace NSQL.Expressions.Functions
{
    public class LogFunction : BaseExpression, ILogFunction
    {
        public INumericExpression Base { get; }
        public INumericExpression Number { get; }

        public LogFunction(INumericExpression @base, INumericExpression number)
        {
            Base = @base;
            Number = number;
        }
        public LogFunction(INumericExpression number)
        {
            Number = number;
        }
        public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.Visit(this);

        public override void Accept(IExpressionVisitor visitor) => visitor.Visit(this);

        public override bool IsValid => (Base is null || Base.IsValid) && Number != null && Number.IsValid;
        protected override IExpression DeepCopy()
        {
            return new LogFunction(Base.DeepClone(), Number.DeepClone())
            {
                Tag = Tag
            };
        }
    }
}